// Copyright 2021 Guoyoko. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Node/CustomizeFlowNode.h"
#include "CustomizeFlowTaskNode.generated.h"

UENUM(BlueprintType)
enum class ECusFTaskResult :uint8
{
	Idle,				
	InProgress,	
	Succeeded,
};


UCLASS(Abstract)
class CUSTOMIZEFLOWRUNTIME_API UCustomizeFlowFlowTaskNode : public UCustomizeFlowNode
{
	GENERATED_UCLASS_BODY()

public:
	/** BlueprintImplementableEvent*/
	UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "BeginTask"), Category = "SelfTask")
	void ReceiveBeginTask();

	UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "TickTask"), Category = "SelfTask")
	void ReceiveTickTask(float DeltaTime);

	UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "EndTask"), Category = "SelfTask")
	void ReceiveEndTask();

	/** End BlueprintImplementableEvent*/

	UFUNCTION(BlueprintCallable, Category = "SelfTask")
	void OnTaskFinished(ECusFTaskResult InTaskResult);

public:

	/** */
	void BeginTask();
	void TickTask(float DeltaTime);
	void EndTask();
	/** */

	void Reset();
	void AddParentNode(UCustomizeFlowFlowTaskNode* InParentNode);
	void AddChildNode(UCustomizeFlowFlowTaskNode* InChildNode);
	void GetChildNodes(TArray<UCustomizeFlowFlowTaskNode*>& NextNodes);
	void GetParentNodes(TArray<UCustomizeFlowFlowTaskNode*>& ParNodes);

public:
	UPROPERTY(BlueprintReadOnly)
	ECusFTaskResult Result;

private:

	UPROPERTY()
	TArray<UCustomizeFlowFlowTaskNode*> ParentNodes;

	UPROPERTY()
	TArray<UCustomizeFlowFlowTaskNode*> ChildNodes;
};

